Skip to content

Refactor duplicate console format helpers and unify integer tag dispatch; add MCPServerID validity API - #52220

Merged
pelikhan merged 4 commits into
mainfrom
copilot/refactor-pkg-console-pkg-constants
Aug 15, 2026
Merged

Refactor duplicate console format helpers and unify integer tag dispatch; add MCPServerID validity API#52220
pelikhan merged 4 commits into
mainfrom
copilot/refactor-pkg-console-pkg-constants

Conversation

Copilot AI commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

This PR addresses duplicate/near-duplicate formatting logic in pkg/console and a semantic-type API gap in pkg/constants. It consolidates redundant implementations while preserving existing call patterns and behavior.

  • pkg/console: collapse exact duplicate TTY style helpers

    • Introduced a shared helper:
      • applyStyleWithTTYAndEnviron(style, text, ttyCheck, environ)
    • Kept applyStdoutStyleWithTTY and applyStderrStyleWithTTY as thin delegators so call-site intent remains explicit.
  • pkg/console: unify integer reflect dispatch for tag formatting

    • Added shared integer dispatcher:
      • applyIntegerFormat(val reflect.Value, baseValue string, format func(int64) string) string
    • Refactored both formatters to use it:
      • applyNumberFormat (via FormatNumber(int(v)))
      • applyFilesizeFormat (via FormatFileSize(v))
    • Removes duplicated type-switch + reflect-kind fallback logic from both paths.
  • pkg/constants: complete semantic type surface

    • Added missing method on MCPServerID:
      • IsValid() bool (non-empty check), aligning with other semantic string types (JobName, StepID, etc.).
  • Focused test updates

    • Added direct coverage for applyStyleWithTTYAndEnviron.
    • Extended semantic-type tests/spec assertions to include MCPServerID.String() and MCPServerID.IsValid().
func applyIntegerFormat(val reflect.Value, baseValue string, format func(int64) string) string {
	// shared int/int64/int32/uint/uint64/uint32 dispatch + reflect.Kind fallback
}

Run context: https://github.com/github/gh-aw/actions/runs/31655027162> Generated by 👨‍🍳 PR Sous Chef · gpt54 · 30.7 AIC · ⌖ 5.28 AIC · ⊞ 8.5K ·

Comment /souschef to run again


Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

Potential security threats were detected in the agent output.

Review the workflow run logs for details.

Run: https://github.com/github/gh-aw/actions/runs/31656629817> Generated by 👨‍🍳 PR Sous Chef · gpt54 · 4.42 AIC · ⌖ 6.21 AIC · ⊞ 8.5K ·

Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 5.89 AIC · ⌖ 5.09 AIC · ⊞ 8.5K ·
Comment /souschef to run again


Branch update requested by pr-sous-chef for run https://github.com/github/gh-aw/actions/runs/31692375821.> Generated by 👨‍🍳 PR Sous Chef · gpt54 · 12.7 AIC · ⌖ 5.21 AIC · ⊞ 8.5K ·

Comment /souschef to run again


Run: https://github.com/github/gh-aw/actions/runs/31694426361> Generated by 👨‍🍳 PR Sous Chef · gpt54 · 7.86 AIC · ⌖ 3.48 AIC · ⊞ 8.5K ·

Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 14.9 AIC · ⌖ 5.13 AIC · ⊞ 8.5K ·
Comment /souschef to run again

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor pkg/console and pkg/constants to resolve duplicates and misplaced functions Refactor duplicate console format helpers and unify integer tag dispatch; add MCPServerID validity API Aug 12, 2026
Copilot AI requested a review from pelikhan August 12, 2026 04:04
@github-actions

Copy link
Copy Markdown
Contributor

👋 Great work consolidating the duplicate formatting logic in pkg/console and completing the semantic type API surface in pkg/constants! This refactoring is clean and focused:

What looks good:

  • Exact duplicates (applyStdoutStyleWithTTY / applyStderrStyleWithTTY) collapsed into a shared helper while keeping call-site intent explicit
  • Near-duplicate reflect dispatchers unified via applyIntegerFormat with a format function callback — removes ~30 duplicated lines including repeated #nosec annotations
  • MCPServerID.IsValid() fills the API gap and aligns with other semantic string types
  • Test coverage added for new shared code and extended for semantic type assertions
  • Diff is tightly scoped to the two packages in scope

This PR is ready for review.

Generated by ✅ Contribution Check · auto · 50.4 AIC · ⌖ 4.51 AIC · ⊞ 8.8K ·

@github-actions

Copy link
Copy Markdown
Contributor

Triage: pr-type:refactor · pr-risk:low · Score 35/100 (impact 10, urgency 10, quality 15)

Recommended action: batch_review (batch: lintmonster-refactor)

Small, self-contained duplicate-code consolidation in pkg/console/pkg/constants (6 files, +72/-46). Draft, CI not yet run. Grouped with similar lint-monster refactor PRs (#52219, #52218, #52212) for combined review.

Generated by 🔧 PR Triage Agent · auto · 44.6 AIC · ⌖ 2.44 AIC · ⊞ 7.8K ·

@github-actions

Copy link
Copy Markdown
Contributor

Triage

Small, mechanical console/constants refactor preserving behavior. CI unstable — recheck before merge.

Generated by 🔧 PR Triage Agent · auto · 41.1 AIC · ⌖ 2.53 AIC · ⊞ 7.8K ·

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

  • Category: refactor
  • Risk: low
  • Score: 41/100 (impact 18 + urgency 10 + quality 13)
  • Recommended action: batch_review
  • Batch: lintmonster-refactor
  • Note: small refactor+tests, part of lintmonster batch

Generated by 🔧 PR Triage Agent · auto · 39.1 AIC · ⌖ 2.59 AIC · ⊞ 7.8K ·

@pelikhan
pelikhan marked this pull request as ready for review August 12, 2026 21:35
Copilot AI balanced review requested due to automatic review settings August 12, 2026 21:35

Copilot AI commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Triage nudge from sous-chef. Please refresh this branch as needed, review current status, and run the pr-finisher skill to move this PR toward maintainer-ready state.

Run: https://github.c...

Triage complete on 94186fe.

  • Branch refresh: not needed (origin/main at b2ef1f3 is already merged into this branch).
  • Reviews: no unresolved review threads found.
  • Checks: inspected latest branch runs and pulled logs for prior failed jobs (31643222091, 31643222155, 31643222139); failures were transient external curl download errors (503/56), not repository-code failures.
  • Local validation on current HEAD passed: make fmt, make lint, make test-unit, make test, make recompile.

No code changes were required in this pass. CI on the current head remains unverified until a maintainer re-triggers workflows.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Triage nudge from sous-chef. Please avoid another no-op pass unless you can identify a remaining blocker on this branch; otherwise leave a brief maintainer handoff from pr-finisher.

Run: https://github.com/github/gh-aw/actions/runs/31696345716

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 23.5 AIC · ⌖ 5.46 AIC · ⊞ 8.5K ·
Comment /souschef to run again

Copilot AI commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Triage nudge from sous-chef. Please avoid another no-op pass unless you can identify a remaining blocker on this branch; otherwise leave a brief maintainer handoff from pr-finisher.

Run: h...

Maintainer handoff from pr-finisher on 94186fe:

  • No remaining actionable blocker found on this branch.
  • Branch refresh not needed (origin/main is already merged into this head).
  • No unresolved review threads.
  • Sous-chef run 31696345716 has no failed jobs.
  • Prior agent-job failures were transient external curl/network errors (503/56), not code regressions.

Ready for human merge once maintainers re-trigger CI on current HEAD (agent pushes/runs do not auto-refresh required checks).

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Triage nudge from sous-chef. This branch appears up to date and prior passes found no actionable code blocker. Please avoid another no-op pass unless something changed; otherwise leave a concise maintainer handoff from pr-finisher.

No unresolved review threads were found.
No failed checks were included in the compact candidate set.
Branch update was requested by sous-chef for run https://github.com/github/gh-aw/actions/runs/31700023913.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 14.9 AIC · ⌖ 5.13 AIC · ⊞ 8.5K ·
Comment /souschef to run again

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

Category: refactor · Risk: low · Priority: medium
Score: 42/100 (impact 18, urgency 8, quality 16)
Recommended action: batch_review (batch: small-refactors)

Refactors duplicate console format helpers and unifies integer tag dispatch; adds MCPServerID validity API. Grouped with other small low-risk refactor PRs.

Generated by 🔧 PR Triage Agent · auto · 61.7 AIC · ⌖ 2.63 AIC · ⊞ 7.8K ·

Copilot AI commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Triage nudge from sous-chef. This branch appears up to date and prior passes found no actionable code blocker. Please avoid another no-op pass unless something changed; otherwise leave a conc...

Maintainer handoff from pr-finisher on 94186fe:

  • No new actionable blocker detected.
  • Branch is up to date with base (origin/main already merged).
  • No unresolved review threads.
  • No failed checks in the compact set; run 31700023913 has no failed jobs.

Ready for human merge after a maintainer re-triggers CI on this HEAD (agent runs/pushes do not refresh required checks).

@github-actions

Copy link
Copy Markdown
Contributor

🔍 PR Triage

Category: refactor · Risk: low · Priority score: 35/100 (impact 12, urgency 8, quality 15)
Recommended action: batch_review
Batch: lintmonster-refactor (with #52218, #52212)

Score breakdown:

  • Impact: Consolidates duplicate TTY style helpers in pkg/console and adds MCPServerID validity API.
  • Urgency: Low — code-quality cleanup, no behavior change intended.
  • Quality: APPROVED review; CI has 1 cancelled run alongside 7 success — worth a re-run check.

Grouped with other lint-monster function-length refactors for a single batched review pass.

Generated by 🔧 PR Triage Agent · auto · 71.4 AIC · ⌖ 2.63 AIC · ⊞ 7.8K ·

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

Category: refactor · Risk: low · Priority: low · Score: 42/100

Impact Urgency Quality
18/50 8/30 16/20

Recommended action: batch_review (batch: small-refactors-2)

Collapses duplicate TTY style helpers in pkg/console and adds an MCPServerID validity API. Low-risk dedup, CI green. Grouped with #52218 for a combined small-refactor review pass.

Generated by 🔧 PR Triage Agent · auto · 58.4 AIC · ⌖ 2.92 AIC · ⊞ 7.8K ·

@github-actions

Copy link
Copy Markdown
Contributor

Triage: refactor / risk: low

Score: 35/100 (impact+urgency+quality) · Priority: medium · Action: batch_review · Batch: lint-cleanup-cluster

Console format helper dedupe + MCPServerID validity API. CI green/skipped.

Automated PR triage — see full report issue for details.

Generated by 🔧 PR Triage Agent · auto · 48.2 AIC · ⌖ 2.57 AIC · ⊞ 7.8K ·

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage\n\n- Category: refactor\n- Risk: low\n- Priority: medium\n- Score: 48/100 (impact 25 + urgency 15 + quality 8)\n- Recommended action: batch_review\n- Batch: refactor-consolidation-cluster\n

Generated by 🔧 PR Triage Agent · auto · 62.8 AIC · ⌖ 2.76 AIC · ⊞ 7.8K ·

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

  • Category: refactor
  • Risk: medium
  • Priority: medium (score: 48/100)
  • Score breakdown: impact 18/50, urgency 20/30, quality 10/20
  • Recommended action: batch_review
  • Batch: refactor-cleanup-cluster
  • Note: CI failing (checkout-cache cancelled), stale ~63h

Automated triage by PR Triage Agent.

Generated by 🔧 PR Triage Agent · auto · 64.3 AIC · ⌖ 2.94 AIC · ⊞ 7.8K ·

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

Category: refactor  |  Risk: medium  |  Score: 44/100

Score breakdown

  • Impact: 20/50
  • Urgency: 10/30
  • Quality: 14/20

Recommended action: batch_review

Batch: refactor-cleanup-cluster

Mixed CI (one cancelled job), one approval.

Generated by 🔧 PR Triage Agent · auto · 68.2 AIC · ⌖ 10.7 AIC · ⊞ 7.8K ·

@pelikhan
pelikhan merged commit 34435b4 into main Aug 15, 2026
27 of 28 checks passed
@pelikhan
pelikhan deleted the copilot/refactor-pkg-console-pkg-constants branch August 15, 2026 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[refactor] pkg/console + pkg/constants: 1 exact duplicate, 3 near-duplicates, 5 misplaced functions

4 participants